import wx from 'weixin-js-sdk'
/*签名 */
const weiXinConfig = (wxConfig)=>{
    wx.config({
        debug: false,
        appId: wxConfig.appId,//'wxe4991dca0fc6f269',
        timestamp: wxConfig.timestamp.toString(),//'1543051182',
        nonceStr: wxConfig.nonceStr,//'10ClPA1p7Zh7g5xMWUztC76B37Rxrx5I',
        signature: wxConfig.signature,//"8f8cc4c64d3ac040d4e9e8caa99cf989235e26b4",
        jsApiList: ["onMenuShareQQ", "onMenuShareWeibo", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQZone","getLocation"]
    });
};
/*分享*/
const weiXinShare=(title, link, imgUrl, desc, Vue)=>{
    wx.ready(() => {
        wx.onMenuShareTimeline({
            title: title,
            link: link,
            imgUrl: imgUrl,
            success: function () {
                Vue.$p_message("成功分享到朋友圈");
            },
            cancel: function () { }
        });
        wx.onMenuShareAppMessage({
            title: title,
            desc: desc,
            link: link,
            dataUrl: "",
            imgUrl: imgUrl,
            success: function () {
                Vue.$p_message("成功分享给微信好友");
            },
            cancel: function () { }
        });
        wx.onMenuShareQQ({
            title: title,
            desc: desc,
            link: link,
            imgUrl: imgUrl,
            success: function () {
                Vue.$p_message("成功分享到QQ好友");
            },
            cancel: function () { }
        });
        wx.onMenuShareWeibo({
            title: title,
            desc: desc,
            link: link,
            imgUrl: imgUrl,
            success: function () {
                Vue.$p_message("成功分享到腾讯微博");
            },
            cancel: function () { }
        });
        wx.onMenuShareQZone({
            title: title,
            desc: desc,
            link: link,
            imgUrl: imgUrl,
            success: function () {
                Vue.$p_message("成功分享分享到QQ空间");
            },
            cancel: function () { }
        });
    });
    wx.error(function (res) {
        alert(JSON.stringify(res));
    });
};
export {
    weiXinConfig,
    weiXinShare
} 

